package com.yeyks.app.controller.base.activity;


import com.yeyks.activity.dal.domain.ActivityList;
import com.yeyks.activity.dal.domain.ActivityNoviceTask;
import com.yeyks.app.annotation.LoadUserId;
import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.param.consumer.UserIdParam;
import com.yeyks.commonReference.append.activity.ActivityNewUserTaskService;
import com.yeyks.commonReference.pojo.param.activity.NewUser.ActivityNewUserTaskReceiveParam;
import com.yeyks.commonReference.service.activity.ActivityBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 新手任务活动 前端控制器
 * </p>
 *
 * @author yun
 * @since 2020-02-24
 */
@Api(tags = "新手活动v4.3.0", description = "新手活动")
@RestController
@RequestMapping("/app/activity/novice/task")
public class ActivityNewUserTaskController {

    @Autowired
    private ActivityBaseService activityBaseService;
    @Autowired
    private ActivityNewUserTaskService activityNewUserTaskService;

    @ApiOperation(value = "活动详情v4.3.0", notes = "活动详情")
    @PostMapping("/detail")
    public AjaxResponseBody<ActivityList> getActivityDetail() {
        return AjaxResponseBody.success(activityBaseService.getActivityDetail(ActivityNewUserTaskService.activity_code));
    }

    @ApiOperation(value = "获取任务列表v4.3.0", notes = "获取任务列表")
    @PostMapping("/list")
    public AjaxResponseBody<List<ActivityNoviceTask>> list(@LoadUserId UserIdParam param) {
        return AjaxResponseBody.success(activityNewUserTaskService.list(param));
    }

    @ApiOperation(value = "完成新手引导v4.3.0", notes = "完成新手引导")
    @PostMapping("/finishOne")
    public AjaxResponseBody finishOne(@LoadUserId UserIdParam param) {
        activityNewUserTaskService.finishOne(param);
        return AjaxResponseBody.success();
    }

    @ApiOperation(value = "领取奖品v4.3.0", notes = "领取奖品")
    @PostMapping("/receive")
    public AjaxResponseBody<ActivityNoviceTask> receive(@LoadUserId @Validated ActivityNewUserTaskReceiveParam param) {
        activityNewUserTaskService.checkEnd();
        return AjaxResponseBody.success(activityNewUserTaskService.receive(param));
    }

}